import {Result} from '@/base/Result';
import {request} from '@/base/Request';
import {Page} from '@/base/Page';
import {Family} from '@/base/model/Family';
import {FamilyMember} from '@/base/model/FamilyMember';
import {TableSort} from '@/base/TableSort';
import {Affiliate} from "@/base/model/Affiliate";
import {FamilyMemberInfo} from "@/base/model/FamilyMemberInfo";
import {Health} from "@/base/model/Health";
import {DeviceUse} from "@/base/model/DeviceUse";

export function getFamilyList(params: {
  pageIndex: number,
  pageSize: number,
  familyname?:string,
  nickname?: string,
  phone?: string,
  createBegin?: string,
  createEnd?: string,
  // companyId?: number[]
}): Promise<Result<Page<Family>>> {
  return request.getPage(Family, '/api/family-info/family', {params});
}

// export function getMember(id: number): Promise<Result<Member>> {
//   return request.get(Member, `/api/member/${id}`);
// }
//
// export function putMember(id: number, params: {
//   password: string,
//   phone: string
// }): Promise<Result<Member>> {
//   let formData = new FormData();
//   Object.keys(params).forEach(x => {
//     formData.append(x, params[x]);
//   });
//   return request.put(Member, `/api/member/${id}`, formData);
// }
//
// export function postMember(params: {
//   password: string,
//   phone: string
// }): Promise<Result<Member>> {
//   let formData = new FormData();
//   Object.keys(params).forEach(x => {
//     formData.append(x, params[x]);
//   });
//   return request.post(Member, '/api/member', formData);
// }
//
// export function deleteMember(id: number): Promise<Result<void>> {
//   return request.delete(`/api/member/${id}`);
// }
//
// export function getMemberNum(): Promise<Result<Number>> {
//   return request.get(Number, '/api/member/num/company');
// }

export function getFamilyMemberList(params: {
  pageIndex: number,
  pageSize: number,
  familyid?: number,
  nickname?: string,
  createBegin?: string,
  createEnd?: string
}): Promise<Result<Page<FamilyMember>>> {
  // Object.assign(params, TableSort());
  return request.getPage(FamilyMember, '/api/family-info/familyMember', {params});
}

export function getMemberInfo(memberId: number) {
  return request.get(FamilyMemberInfo, `/api/member-info/${memberId}`);
}

export function getMemberInfos(params: {
  memberId: number,
  infoAll: number,
}) {
  return request.get(FamilyMemberInfo, `/api/member-info/${params.memberId}`, {params});
}

export function getHealthList(params: {
  pageIndex: number,
  pageSize: number,
  memberId: number,
  sortDirection?: string,
  createBegin?: string,
  createEnd?: string
}): Promise<Result<Page<Health>>> {
  return request.getPage(Health, '/api/family-info/health', {params});
}
export function getDeviceUseList(params: {
  pageIndex: number,
  pageSize: number,
  sortDirection: string,
  memberId?: number,
  createBegin?: string,
  createEnd?: string,
  companyId?: number,
  deviceId?: number
}) {
  return request.getPage(DeviceUse, '/api/family-info/use', { params });
}
